<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../layuimini/css/public.css" media="all">
    <link rel="stylesheet" href="../layuimini/lib/lay-module/step-lay/step.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
    <!-- 引入Vue -->
	<script src="../../js/vue.min.js"></script>
	<!-- 引入axios -->
	<script type="text/javascript"
		src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.0/axios.min.js"></script>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<body>
<div class="layui-row">
	<div class="layui-col-md-offset1" style="background-color: #fff;border-left: solid #0eff0063 5px;margin-bottom: 50px;">
		<h2>温馨提示:</h2>
		<hr>
		<p style="text-indent: 10%">管理员创建的账号点<B style="color: red">确认保存</B>会给出<b style="color: red">六位数</b>的账号。</p>
		<p style="text-indent: 10%">管理员创建的初始密码是：<b style="color: red;">123456</b></p>
	</div>
</div>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">姓名</label>
        <div class="layui-input-block">
            <input type="text" name="realName" lay-verify="required|ZWCheck" lay-reqtext="用户名不能为空" placeholder="请输入姓名" value="" class="layui-input">
            <tip>填写管理人的真实姓名。</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">性别</label>
        <div class="layui-input-block">
            <input type="radio" name="sex" value="男" title="男" checked="">
            <input type="radio" name="sex" value="女" title="女">
        </div>
    </div>
    <div class="layui-form-item" id = "">
	   <form class="layui-form" action="" style="margin-left: 3%;">
            <div class="layui-form-item" id="area-picker">
                <div class="layui-form-label">住址</div>
                <div class="layui-input-inline" style="width: 200px;">
                    <select name="province" class="province-selector" required lay-verify="required" lay-filter="province-1">
                        <option value="">请选择省</option>
                    </select>
                </div>
                <div class="layui-input-inline" style="width: 200px;">
                    <select name="city" class="city-selector" required lay-verify="required" lay-filter="city-1">
                        <option value="">请选择市</option>
                    </select>
                </div>
                <div class="layui-input-inline" style="width: 200px;">
                    <select name="county" class="county-selector" required lay-verify="required" lay-filter="county-1">
                        <option value="">请选择区</option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">手机</label>
        <div class="layui-input-block">
            <input type="text" name="telphone" lay-verify="required|phone" lay-reqtext="手机不能为空" placeholder="请输入手机" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-block">
            <input type="email" name="email" lay-verify="required|email" placeholder="请输入邮箱" value="" class="layui-input">
            <tip>请填写管理员的qq邮箱。</tip>
        </div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label">负责人</label>
        <div class="layui-input-block">
            <input type="text" name="superior" placeholder="请输入负责人" lay-verify="required|ZWCheck" value="" class="layui-input">
            <tip>请填写正确的负责人。</tip>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注信息(简介)</label>
        <div class="layui-input-block">
            <textarea name="introduction" class="layui-textarea" placeholder="请输入备注信息"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script src="../layuimini/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="../layuimini/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['layer', 'form','layarea'], function () {
        var form = layui.form,
            layer = layui.layer,
            layarea = layui.layarea,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
        	var location = ""+data.field.province + data.field.city + data.field.county;
        	var params = new URLSearchParams();
        	params.append("realName",data.field.realName);
        	params.append("sex",data.field.sex);
        	params.append("location",location);
        	params.append("telphone",data.field.telphone);
        	params.append("email",data.field.email);
        	params.append("superior",data.field.superior);
        	params.append("introduction",data.field.introduction);
        	axios.post("../../manageBack/addManages.s",params).then(res=>{
        		var info = res.data.data;
        		console.log(info);
        		//提示信息
        		 var index = layer.alert("账号："+info.account
        				 +"<br/>密码："+info.pwd, {
                     title: '通知'
                 } ,function () {
     				
                     // 关闭弹出层
                     layer.close(index);
					 //退出此页面
                     var iframeIndex = parent.layer.getFrameIndex(window.name);
                     parent.layer.close(iframeIndex);
     				
                 });

                 return false;
        	});
        });
        //加载省市县区三级联动下拉选择器
        layarea.render({
            elem: '#area-picker',
            /* change: function (res) {
                //选择结果
                console.log(res);
            } */
        });
        //自定义验证规则
        form.verify({
        	//数组的两个值分别代表：[正则匹配、匹配不符时的提示文字]
		  	ZWCheck: [
			    /^[\u0391-\uFFE5]+$/
			    ,'只允许输入中文'
		  	]
		});
    });
</script>
</body>
</html>